<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#one" data-toggle="tab">设备故障记录</a></li>
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        <a href="javascript:;" class="btn btn-success btn-add" title="添加"><i class="fa fa-plus"></i> 添加</a>
                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="刷新"><i class="fa fa-refresh"></i></a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover" width="100%">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var options = {
            url: $.fn.bootstrapTable.defaults.extend.index_url,
            pk: 'id',
            sortName: 'fault_time',
            sortOrder: 'desc',
            columns: [
                [
                    {checkbox: true},
                    {field: 'id', title: 'ID'},
                    {field: 'equipment_name', title: '设备名称'},
                    {field: 'fault_time', title: '故障时间', formatter: Table.api.formatter.datetime},
                    {field: 'fault_type', title: '故障类型'},
                    {field: 'fault_description', title: '故障描述'},
                    {field: 'reporter', title: '报告人'},
                    {field: 'repair_time', title: '修复时间', formatter: Table.api.formatter.datetime},
                    {field: 'repairer', title: '维修人'},
                    {field: 'downtime', title: '停机时长(小时)'},
                    {field: 'repair_cost', title: '维修费用'},
                    {field: 'status', title: '状态', searchList: {0:'待维修',1:'维修中',2:'已修复'}, formatter: Table.api.formatter.status},
                    {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                ]
            ]
        };
        var table = $("#table").bootstrapTable(options);
        
        $(document).on("click", ".btn-add", function () {
            Fast.api.open("equipment/fault/add", "添加故障记录");
        });
        
        $(document).on("click", ".btn-refresh", function () {
            $("#table").bootstrapTable('refresh');
        });
    });
</script>

